﻿@using QDT.Core
@using QDT.Core.Projects
@model RepaymentScheme
@{
    var project = ViewData["Project"] as Project;

    bool repay = true;

}
<script type="">
    function cfm() {
        if (!confirm("确认提交还款？")) {
            window.event.returnValue = false;
        }
    }

</script>
<div class="main_title">
    还款计划
</div>
<div class="blank5">
</div>
<div class="button_row">
    <div class="grid_top">
    </div>
    <table class="grid" style="text-align: center;">
        <thead>
            <tr>
                <th>
                    编号
                </th>
                <th>
                    借款人
                </th>
                <th>
                    借款人余额
                </th>
                <th>
                    标题
                </th>
                <th>
                    借款金额
                </th>
                <th>
                    借款年利率
                </th>
                <th>
                    借款期限
                </th>
                <th>
                    已还总额
                </th>
                <th>
                    待还余额
                </th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>
                    @project.ID
                </td>
                <td>
                    @Html.ActionLink(Html.F().GetUserName(project.UserID), "Index", "User", new
                    {
                        userid = project.UserID
                    }, new { target = "_blank" })
                </td>
                <td>
                    @Html.F().GetUserMoney(project.UserID)
                </td>
                <td>
                    @project.Name
                </td>
                <td>
                    <span>@project.BorrowAmount.ToMoney()</span> 元
                </td>
                <td>
                    @project.Rate.ToString("0.00")%
                </td>
                @if (project.RepayTimeType == 0)
                {
                    <td>
                        @project.RepayTime 天
                    </td>
                }
                @if (project.RepayTimeType == 1)
                {
                    <td>
                        @project.RepayTime 个月
                    </td>
                }
                <td>
                    @Model.RepayMoney.ToMoney()
                </td>
                <td>
                    @Model.WaitRepayMoney.ToMoney()
                </td>
            </tr>
        </tbody>
    </table>
    <div class="grid_foot">
    </div>
</div>
<div class="blank5">
</div>
<div class="grid_box">
    <div class="grid_top">
    </div>
    <table class="grid">
        <thead>
            <tr>
                <th>
                    期次
                </th>
                <th>
                    还款日
                </th>
                <th>
                    已还金额
                </th>
                <th>
                    待还本息
                </th>
                <th>
                    还款类型
                </th>
                <th>
                    状态
                </th>
                <th>
                    操作
                </th>
            </tr>
        </thead>
        @foreach (var m in Model.Stages)
        {
            var isTime = m.Time.Date.Equals(DateTime.Now.Date);
            <tr>
                <td>@m.Stage
                </td>
                <td>
                    @m.Time.ToShortDateString()
                </td>
                <td style="color: green;">
                    @(m.IsRepay ? m.Ammount.ToMoney().ToString() : "")
                </td>
                <td style="color: red">
                    @(!m.IsRepay ? m.Ammount.ToMoney().ToString() : "")
                </td>
                <td>
                    @m.Remark
                </td>
                <td>@m.Status
                </td>
                <td>
                    @if (repay && !m.IsRepay)
                    {
                        @Html.ActionLink(isTime ? "还款" : " ", "PostRefund", new { id = project.ID, stage = m.Stage }, new { onClick = "cfm()" })
@*                        @Html.ActionLink("还款", "PostRefund", new { id = project.ID, stage = m.Stage }, new { onClick = "cfm()" })*@
                   repay = false;
                    }
                </td>
            </tr>
        }
    </table>
    <div class="grid_foot">
    </div>
</div>
<div class="blank5">
</div>
